<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>发布订阅模式</title>
    <style>
        #div1{
            width:100px;
            height:100px;
            border:1px solid #ccc;
            margin-top:20px;
        }
    </style>
</head>
<body>
    <input type="button" id="btn1" value="点击我吧"/>

    <div id="div1"></div>
    
</body>
</html>
<script src="js/Event.js"></script>
<script>
    Event.trigger("add",1);
    //a模块
    var a = (function(){
        var count = 0;
        document.getElementById("btn1").onclick = function(){
            Event.trigger("add",count++);
        }
    })();

    //b模块
    var b = (function(){

        var oDiv = document.getElementById("div1");
        Event.add("add",function(num){
            oDiv.innerHTML = num;
        });
    })();

    

    
</script>
